package framework;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;



public class CSVReader implements ICSVReader {
	private String[] lines;
	private BufferedReader bReader; 
	private String[] allLines = null;
	
	public CSVReader(String fileName){
		try {
			bReader = new BufferedReader(new FileReader(fileName));
			int lines = 0;
			while(bReader.readLine()!=null)
				lines++;
			
			allLines = new String[lines];
			
			bReader = new BufferedReader(new FileReader(fileName));
			int line = 0;
			String content = "";
			while((content = bReader.readLine())!=null){
				allLines[line] = content;
				line++;
			}
				
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally{
			if(bReader!=null)
				try {
					bReader.close();
				} catch (IOException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		}
	}

	@Override
	public String getLine(int lineNum) {
		String content = null;
		int i = 0;
		String lineToReturn = null;
		try {
			return allLines[lineNum];
		} catch (Exception e) {
			e.printStackTrace();
			return null;
		} finally{
			
		}
	}

	@Override
	public boolean appendToLine(int lineNum, String textToAppend) {
		// TODO Auto-generated method stub
		return false;
	}

	
	

	
}
